package org.robot.scm.platform.server.handler;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import java.io.IOException;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * app发布
 */
@Slf4j
@NoArgsConstructor
public class WgtPackageHandler extends BaseHandler implements HttpHandler {

    @Override
    public String getUri() {
        return "/wgtPackage";
    }

    @Override
    public void handle(HttpExchange exchange) throws IOException {
        Process process = Runtime.getRuntime().exec("wgt.bat");
        try {
            process.waitFor();
        } catch (Exception e) {
            log.error("error", e);
        } finally {
            process.destroyForcibly();
        }
        sendSuccessResponse(exchange, "打包成功请重启");
    }

}
